/**
 * @file dump.h
 *
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

#ifndef ACL_DUMP_H_
#define ACL_DUMP_H_

#include "acl/acl_base.h"
#include "common_inner.h"

namespace acl {
    struct AclDumpInfo {
        std::string modelName;
        std::vector<std::string> layer;
        std::vector<std::string> watcherNodes;
        bool isLayer = false; // Whether the label of "layer" exists
        bool isModelName = false; // Whether the label of "model_name" exists
    };

    struct AclDumpConfig {
        std::string dumpPath;
        std::string dumpMode;
        std::vector<AclDumpInfo> dumpList;
        std::string dumpOpSwitch;
        std::string dumpDebug;
        std::string dumpScene;
        std::string dumpStep;
        std::string dumpData;
        std::string dumpLevel;
        std::vector<std::string> dumpStats;
    };

    bool NeedDump(const AclDumpConfig &cfg);

    class AclDump {
    public:
        static aclError HandleDumpConfig(const char_t *const configPath);
        static AclDump &GetInstance();
        void SetAclDumpFromAclInitFlag(const bool flag)
        {
            aclDumpFromAclInitFlag_ = flag;
        }
        bool GetAclDumpFromAclInitFlag() const
        {
            return aclDumpFromAclInitFlag_;
        }
        void SetAdxInitFromAclInitFlag(const bool flag)
        {
          adxInitFromAclInitFlag_ = flag;
        }
        bool GetAdxInitFromAclInitFlag() const
        {
          return adxInitFromAclInitFlag_;
        }

    private:
        static aclError HandleDumpCommand(const AclDumpConfig &aclCfg);
        bool aclDumpFromAclInitFlag_ = false;
        bool adxInitFromAclInitFlag_ = false;
        ~AclDump() = default;
        AclDump() = default;
    };
}

#endif // ACL_DUMP_H_
